home *** CD-ROM | disk | FTP | other *** search
- unit HResultDecoderU;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- StdCtrls;
-
- type
- TForm1 = class(TForm)
- edtHRESULT: TEdit;
- Label1: TLabel;
- lblS: TLabel;
- GroupBox1: TGroupBox;
- lblR: TLabel;
- lblC: TLabel;
- lblN: TLabel;
- lblMsgID: TLabel;
- lblFacility: TLabel;
- lblSCode: TLabel;
- procedure FormCreate(Sender: TObject);
- procedure edtHRESULTChange(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- uses
- TypInfo;
-
- {$R *.DFM}
-
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- if Assigned(edtHRESULT.OnChange) then
- edtHRESULT.OnChange(edtHRESULT)
- end;
-
- procedure TForm1.edtHRESULTChange(Sender: TObject);
- var
- HRes: HResult;
- Facility, SCode: Integer;
- TmpStr: String;
- const
- Sev: array[Boolean] of String = ('Failure', 'Success');
- begin
- try
- HRes := StrToInt(edtHRESULT.Text);
- lblS.Caption := Format('Severity: %s',
- [Sev[HResultFacility(HRes) = Severity_Success]]);
- lblR.Caption := Format('NT''s second severity bit: %s',
- [BooleanIdents[(HRes shr 30) and $1 <> 0]]);
- lblC.Caption := Format('NT''s C field: %s',
- [BooleanIdents[(HRes shr 29) and $1 <> 0]]);
- lblN.Caption := Format('Mapped NT status field: %s',
- [BooleanIdents[HRes and Facility_NT_Bit <> 0]]);
- lblMsgID.Caption := Format('Msg id: %s',
- [BooleanIdents[(HRes shr 27) and $1 <> 0]]);
- Facility := HResultFacility(HRes);
- TmpStr := IntToHex(Facility, 2);
- case Facility of
- FACILITY_NULL: TmpStr := 'FACILITY_NULL';
- FACILITY_RPC: TmpStr := 'FACILITY_RPC';
- FACILITY_DISPATCH: TmpStr := 'FACILITY_DISPATCH';
- FACILITY_STORAGE: TmpStr := 'FACILITY_STORAGE';
- FACILITY_ITF: TmpStr := 'FACILITY_ITF';
- FACILITY_SSPI: TmpStr := 'FACILITY_SSPI';
- FACILITY_WIN32: TmpStr := 'FACILITY_WIN32';
- FACILITY_WINDOWS: TmpStr := 'FACILITY_WINDOWS';
- FACILITY_CONTROL: TmpStr := 'FACILITY_CONTROL';
- FACILITY_CERT: TmpStr := 'FACILITY_CERT';
- FACILITY_INTERNET: TmpStr := 'FACILITY_INTERNET';
- end;
- lblFacility.Caption := 'Facility code: ' + TmpStr;
- SCode := HResultCode(HRes);
- lblSCode.Caption := Format('SCODE: $%x', [SCode]);
- except
-
- end
- end;
-
- end.
-